/***********************************************************************************************************************
**	filename: net_server.h
**	author: Echo Zhang @2021-02-04
**  e-mail: not_xx@126.com
***********************************************************************************************************************/

#ifndef NET_SERVER_INCLUDED
#define NET_SERVER_INCLUDED

#include <uv.h>

typedef struct net_server                       NetServer_ST;

typedef void (*NetServer_Recv_FT)(NetServer_ST *server, const ui8 data[], Size_DT dataLen);

struct net_server{
    void *data;
    ui32 packetSize;
    uv_udp_t udpServer;
    uv_timer_t timer;
    struct sockaddr *targetAddr;
    NetServer_Recv_FT recvFunc;
};

bool net_server_init(NetServer_ST *server, NetServer_Recv_FT recvFunc, ui32 packetSize);
bool net_server_start(NetServer_ST *server, ui16 port);
void net_server_send_udp_data(NetServer_ST *server, const ui8 data[], Size_DT dataLen);
void net_server_stop(NetServer_ST *server);


#endif	/* NET_SERVER_INCLUDED */

/***********************************************************************************************************************
**	endline
***********************************************************************************************************************/
